<?php

if (isset($_POST["name"])) {
    echo $_POST["name"];
    echo $_POST["boy"];
} else {
    echo 'NOTHING';
}

?>

<?php
$servername = "mysql";
$username = "root";
$password = "password";
$dbname = "test";

// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);
// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}
if (isset($_POST["name"])) {
    $sql = "insert into text1(name,boy) values('".$_POST["name"]."','".$_POST["boy"]."')";
} else if (isset($_POST["id"])) {
    $name = $_POST["name"];
    $boy = $_POST["boy"];
    $id = $_POST["id"];
    $sql = "update text1 set name = '$name', boy= '$boy' where name = '$id'";
}

if ($conn->query($sql) === TRUE) {
    echo "成功";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>
<ul>
    <li><a href="/crud/form_user.php">添加.html</a></li>
    <li><a href="/crud/chaxun.php">列表</a></li>
</ul>




